package sample.stream.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import org.springframework.stereotype.Service;
import sample.stream.channel.MySource;
import sample.stream.service.IMessageProvider;

@Service("kafkaSourceMessageProviderImpl")
@EnableBinding(MySource.class)
public class KafkaSourceMessageProviderImpl implements IMessageProvider {

    @Autowired
    MessageChannel myoutput;

    @Override
    public String send() {
        String message = "I'm kafkaoutput provider!";
        myoutput.send(MessageBuilder.withPayload(message).build());
        System.out.println(message);
        return message;
    }
}
